<template>
  <el-dialog
    top="30px"
    width="1000px"
    class="dialog-sm"
    append-to-body
    :title="editTitle"
    :visible.sync="visible"
    :close-on-click-modal="false"
    :before-close="beforeClose"
  >
    <renewal-base
      ref="baseRef"
      :visible="visible"
      :renewal-data="renewalData"
      :view-mode="viewMode"
      v-bind="$attrs"
      v-on="$listeners"
    ></renewal-base>
  </el-dialog>
</template>

<script>
import RenewalBase from '@/credit/views/city/risk/RenewalBase'

const enumViewLabel = {
  0: '修改',
  1: '审批',
  2: '完成',
  3: '查看',
}

export default {
  components: {
    RenewalBase,
  },
  props: {
    visible: Boolean,
    renewalData: {
      type: Object,
      default: () => ({}),
    },
    viewMode: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {}
  },
  computed: {
    isAddEdit() {
      return !this.renewalData.credit_extended_loan_id
    },
    editType() {
      return +this.renewalData.extended_loan_type || 1
    },
    editTitle() {
      return this.isAddEdit
        ? '展期续贷登记'
        : (this.editType === 1 ? '展期' : '续贷') + (enumViewLabel[this.viewMode] || '')
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    beforeClose() {
      this.$refs.baseRef && this.$refs.baseRef.beforeClose()
      this.$emit('update:visible', false)
    },
  },
}
</script>

<style lang="scss" scoped></style>
